'Input devices'



To tell the truth, I'm still having a hard time when reading the datasheet. So, I've been looking for people's explanation on the microcontroller. The most important part for me now, is the use of pins. When to use analog or digital pins. Analog Input Pins can be used almost identically to the digital pins, using the aliases A0, A1, etc... So the result in the code would be a LOW or HIGH variation. The difference is the way we use them to read analog sensors such as temperature, flex (as used in the following exercises), potentiometers or light level sensors. An analog signal varies in voltage levels. The datasheet cautions against "switching analog pins in close temporal proximity to making A/D readings (analogRead) on other analog pins. This can cause electrical noise and introduce jitter in the analog system. It may be desirable, after manipulating analog pins (in digital mode), to add a short delay before using analogRead() to read other analog pins."

Other thing I found interesting when reading the datasheet and further read about, is the "Interrupt pins". These two pins, can get the attention of the CPU at any instant. Interrupting the data of ATmega328P. IN0 – INT 0 and INT 1 in pinout diagram. Even though I didn't use these pins for the following exercises. I'll try them some time to see how they work.

And the last thing I could further use and the ATmega328P has is the "Timers modules". According to the datasheet, the microcontroller has two internal timers. They could be used for making counters and generate pulses. Would be nice if I relate the time to the reading of hand gestures as mentioned in the last two exercises. The timers can use the internal and external clock to operate (which I'm not sure what it refers to). And the microcontroller also has an internal pin that could be used to count in relation to the external pulses. OC0B, OC0A, OC1A, OC1B, OC2A, and OC2B in the pinout diagram.


At home, I have a few sensors - a potentiometer, a soft potentiometer and a flex sensor (I recently bought an RGB sensor, although by the time I started the activity didn't). As I used the potentiometer during last week, I felt like changing to the flex sensor. To begin I needed to understand the common constants, variables, and functions used for the sensors, so I looked for examples on the web and found a basic tutorial by "Arduino automotive" copied the code and plugged everything together to see how the sensor reacted when bending.

Nice! So then (shown on the second video), I had to filter the data retrieved by the sensor. Last class, Óscar explained different methods/formulas that are used to filter sensor data. Such as average, gradients, and convolution. To begin I made an average with the data retrieved from the Flex Sensor. In the video, it is hard to notice a big difference. But in reality, I did notice especially on the timing of flashes.

I got a bit too excited about this. And I wanted to see if I could place the sensor on my hand and bend it. This took longer than expected... the sensor was falling every time I tried to place it on my hand and when opening the serial monitor in Arduino, I was not able to see anything!!!!!! So, yes... The first thing that came to my mind was using the clothespin to hold down the cables and sensor together as well as making enough pressure to send the data. It worked!

The gesture I'm making means "sí" / "yes" in Mexico and if you put close attention to the led and look for a Morse translator you'll find the same answer (or at least I think you will).


Making my own sensors

I saw a few examples on the web of flex sensors attached to gloves, to track gestures. I made my flex sensors (for now only 3) to start experimenting and see the outcomes. I watched some tutorials, but sadly most of them had a lot more things than I can't get now (👑🦠). So, I followed the simplest (the one Edu recommended us to do in class).

Steps to be taken:
  1. Cut around 25/30cm long and 1cm wide, strips of paper (preferably thicker such as cardboard... obviously not to thick otherwise you'll not be able to bend then easily with your fingers).
  2. Make a half-cut at the center of the strips, for then to bend them.
  3. Take a pencil (the higher h number the better - I used a 6h) and fill one of the sides of the strip.
  4. Cut aluminum foil and fold 2 pieces into small thin lines (make them a bit longer for them to reach the opposite side of the paper).
  5. Paste the aluminum foils on the pencil side. Make sure they are not very close to each other neither touch. To paste them I used double-sided tape.
  6. Fold the aluminum foils to the opposite side of the paper and bend the paper strip.
  7. Use masking tape to put both sides of the paper together.
  8. Solder (This was the hardest part, as the solder wire didn't attach to the aluminum foil) after getting done with it, I put insulating tape and trying to stretch it to the maximum to make pressure on the cables and the aluminum foil tips).
  9. Test results

Back to the professional sensor

On my last presentation for Design Dialogues, I started talking and wondering if it is possible to recreate visual images from sounds and trigger those sounds using gestures. With the intent of redefining visual tools and therefore drawings, paintings or even art. I started using machine learning. I need a lot more hours on coding and training it, so, for now, I paused that path. I'd love to print the visual drawings or geometries that come out from this in braille, emboss or deboss for the blind people and visually impaired touch the outcome of what they can do. But I don't know if I'll have time to do it.

Back to FabAcademy, as I wanted to make visuals I needed to find a tutorial that linked sensors to other programming languages. I found this. It is great because lately, I've been falling in love with processing and javascript. First test:

Files: I'm not sure if it was in class or outside, but at some point, I came across John Whitney's graphics. I found them fascinating!! After a while, I searched if anyone had already tried representing similar drawings on processing or javascript and luckily yes! Alexander Miller has one tutorial, referencing Whitney's drawings. I don't remember a lot of sin and cos functions, but after playing around with them I could see the outcomes drawing, I changed the value of my sensor a few times to test the different outcomes and in the end I used a variation of multiples and dividends in relation to the numbers of the sin and cos. It worked!

I'm excited to see what other things I can do with the sensors :)